package cn.semcorp.zhuhaizj.quartzConfig;

import cn.semcorp.zhuhaizj.quartzJob.TobeTrainingJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzTrainingConfiguration {

    @Bean
    public JobDetail showTrainingJob(){
        return JobBuilder.newJob(TobeTrainingJob.class)
                .withIdentity("tobeTrainingJob")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showTrainingTrigger(){
        CronScheduleBuilder cron =
                CronScheduleBuilder.cronSchedule("0 0 */4 * * ? *");
//                CronScheduleBuilder.cronSchedule("0/30 * * * * ? *");
        return TriggerBuilder.newTrigger()
                .withSchedule(cron)
                .withIdentity("showTrainingTrigger")
                .forJob(showTrainingJob())
                .build();
    }
}
